﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.components.mainmenu {
    import reprise.ui.*;
    import flash.events.*;
    import reprise.controls.*;
    import flash.utils.*;
    import net.wooga.pets.views.components.*;
    import net.wooga.pets.constants.*;
    import net.wooga.pets.utils.*;

    public class MainMenu extends UIComponent {

        private var _backgroundBelow:UIComponent;
        private var _backgroundAbove:UIComponent;
        private var _topMenuDisplay:UIComponent;
        private var _bottomMenuDisplay:UIComponent;
        private var _tabButtonFriendsLabel:Label;
        private var _tabButtonPetsLabel:Label;
        private var _tabButtonSymbolsLabel:Label;
        private var _inventory:UIComponent;
        private var _tabRadioButtonGroup:RadioButtonGroup;
        private var _shopMenu:ShopMenu;
        private var _visitFriendsPanel:UIComponent;
        private var _shopButton:LabelButton;
        private var _giftsButton:SimpleButton;
        private var _tabButtonInventory:RadioButton;
        private var _shopLabel:Label;
        private var _achievementButton:LabelButton;
        private var _achievementsLabel:Label;
        private var _progressDisplay:ClipComponent;
        private var _tabDisplays:Dictionary;
        private var _collectionButton:LabelButton;
        private var _collectionLabel:Label;

        public function MainMenu(){
            this._tabDisplays = new Dictionary();
            super();
        }
        public function setNumberOfAchievements(_arg1:int):void{
            this._achievementsLabel.setLabel(String(_arg1));
            this._achievementsLabel.setVisibility((_arg1 > 0));
        }
        public function setNumberOfFreeSlots(_arg1:int):void{
            this._shopLabel.setLabel(String(_arg1));
            this._shopLabel.setVisibility((_arg1 > 0));
        }
        public function setNumberOfCompletedCollections(_arg1:int):void{
            this._collectionLabel.setLabel(String(_arg1));
            this._collectionLabel.setVisibility((_arg1 > 0));
        }
        public function setLabels(_arg1:String, _arg2:String, _arg3:String):void{
            this._tabButtonFriendsLabel.setLabel(_arg1);
            this._tabButtonPetsLabel.setLabel(_arg2);
            this._tabButtonSymbolsLabel.setLabel(_arg3);
        }
        public function setGiftButtonVisible(_arg1:Boolean=true):void{
            this._giftsButton.setVisibility(_arg1);
        }
        public function showInventoryOnly():void{
            var _local2:UIComponent;
            this.show();
            var _local1:Array = children();
            for each (_local2 in _local1) {
                _local2.hide();
            };
            this._inventory.show();
        }
        public function showAll():void{
            var _local2:UIComponent;
            this.show();
            var _local1:int;
            while (_local1 < this.children().length) {
                UIComponent(this.children()[_local1]).show();
                _local1++;
            };
            this._shopMenu.hide();
            _local2 = this._tabDisplays[GameConstants.MENU_TAB_PETS];
            _local2.hide();
            this._visitFriendsPanel.hide();
        }
        public function setInventoryButtonVisible(_arg1:Boolean):void{
            this._tabButtonInventory.setVisibility(_arg1);
        }
        public function setPatientButtonVisible(_arg1:Boolean):void{
            var _local2:RadioButton = getElementsByClassName("tabButtonPets")[0];
            _local2.setVisibility(_arg1);
        }
        public function setShopButtonVisible(_arg1:Boolean):void{
            this._shopButton.setVisibility(_arg1);
        }
        public function switchTab(_arg1:String):void{
            var _local2:UIComponent;
            this._tabRadioButtonGroup.selectRadioButtonWithData(_arg1);
            for each (_local2 in this._tabDisplays) {
                _local2.hide();
            };
            _local2 = this._tabDisplays[_arg1];
            _local2.show();
        }
        public function get tabRadioButtonGroup():RadioButtonGroup{
            return (this._tabRadioButtonGroup);
        }
        public function get achievementButton():LabelButton{
            return (this._achievementButton);
        }
        public function get giftsButton():SimpleButton{
            return (this._giftsButton);
        }
        public function get collectionButton():LabelButton{
            return (this._collectionButton);
        }
        public function get shopButton():LabelButton{
            return (this._shopButton);
        }
        override protected function initialize():void{
            super.initialize();
            cssID = "mainMenu";
            addCSSClass("myriadProFont");
        }
        override protected function createChildren():void{
            this._visitFriendsPanel = VisitFriendsPanel(addChild(new VisitFriendsPanel()));
            this.createBackground();
            this.createMenuDisplays();
            this._shopMenu = ShopMenu(addChild(new ShopMenu()));
            this.createGiftsButton();
            var _local1:FriendsTabDisplay = FriendsTabDisplay(this._bottomMenuDisplay.addChild(new FriendsTabDisplay()));
            _local1.hide();
            var _local2:PatientTabDisplay = PatientTabDisplay(this._bottomMenuDisplay.addChild(new PatientTabDisplay()));
            _local2.hide();
            var _local3:InventoryTabDisplay = InventoryTabDisplay(this._bottomMenuDisplay.addChild(new InventoryTabDisplay()));
            _local3.hide();
            this._tabDisplays[GameConstants.MENU_TAB_FRIENDS] = _local1;
            this._tabDisplays[GameConstants.MENU_TAB_PETS] = _local2;
            this._tabDisplays[GameConstants.MENU_TAB_INVENTORY] = _local3;
            this._topMenuDisplay.addChild(this.createTabNavigation());
            var _local4:UIComponent = RepriseUtils.addComponent(this._topMenuDisplay, "buttonDisplay");
            this._shopButton = this.createButton(_local4, "shop");
            this._shopLabel = RepriseUtils.addLabel(this._shopButton, "numberLabel");
            this._shopButton.addEventListener(MouseEvent.CLICK, this.onShopButtonClick);
            RepriseUtils.addComponent(_local4, "verticalLine");
            this._collectionButton = this.createButton(_local4, "collection");
            this._collectionLabel = RepriseUtils.addLabel(this._collectionButton, "numberLabel");
            RepriseUtils.addComponent(_local4, "verticalLine biggerMarginLeft");
            this._achievementButton = this.createButton(_local4, "achievement");
            this._achievementsLabel = RepriseUtils.addLabel(this._achievementButton, "numberLabel");
            this.createProgressDisplay();
            this._inventory = UIComponent(addChild(new InventoryDisplay()));
        }
        private function createButton(_arg1:UIComponent, _arg2:String):LabelButton{
            var _local3:LabelButton = RepriseUtils.addLabelButton(_arg1, ("button myriadProFont " + _arg2));
            RepriseUtils.addComponent(_local3, (_arg2 + "Icon"));
            return (_local3);
        }
        private function createProgressDisplay():void{
            this._progressDisplay = RepriseUtils.addClipComponent(this._topMenuDisplay, "", new TreatmentProgressDisplay());
        }
        private function createTabNavigation():UIComponent{
            var _local1:UIComponent = addComponent("tabNavigationDisplay");
            var _local2:RadioButton = RadioButton(_local1.addComponent("tabButtonFriends tabButton", null, RadioButton));
            _local2.setData(GameConstants.MENU_TAB_FRIENDS);
            _local2.setGroupName("tab_navigation");
            this._tabButtonFriendsLabel = Label(_local2.addComponent("tabLabel myriadProFont", null, Label));
            var _local3:RadioButton = RadioButton(_local1.addComponent("tabButtonPets tabButton", null, RadioButton));
            _local3.setData(GameConstants.MENU_TAB_PETS);
            _local3.setGroupName("tab_navigation");
            this._tabButtonPetsLabel = Label(_local3.addComponent("tabLabel myriadProFont", null, Label));
            this._tabButtonInventory = RadioButton(_local1.addComponent("tabButtonInventory tabButton", null, RadioButton));
            this._tabButtonInventory.setData(GameConstants.MENU_TAB_INVENTORY);
            this._tabButtonInventory.setGroupName("tab_navigation");
            this._tabButtonSymbolsLabel = Label(this._tabButtonInventory.addComponent("tabLabel myriadProFont", null, Label));
            this.setInventoryButtonVisible(false);
            this._tabRadioButtonGroup = _local3.group();
            this._tabRadioButtonGroup.addEventListener(Event.CHANGE, this.tabRadioButtonGroup_change);
            _local2.selected = true;
            return (_local1);
        }
        private function createBackground():void{
            this._backgroundBelow = addComponent("backgroundBelow");
            this._backgroundAbove = addComponent("backgroundAbove");
        }
        private function createMenuDisplays():void{
            this._topMenuDisplay = addComponent("menuDisplayTop");
            this._bottomMenuDisplay = addComponent("menuDisplayBottom");
        }
        private function onShopButtonClick(_arg1:MouseEvent):void{
            this._shopMenu.show();
        }
        private function tabRadioButtonGroup_change(_arg1:Event):void{
            var _local2:RadioButtonGroup = RadioButtonGroup(_arg1.currentTarget);
            var _local3:String = _local2.selectedRadioButton().data();
            this.switchTab(_local3);
        }
        private function createGiftsButton():void{
            this._giftsButton = RepriseUtils.addSimpleButton(this._topMenuDisplay, "giftsButton");
        }

    }
}//package net.wooga.pets.views.components.mainmenu 
